package com.ljh.account.service;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.ljh.account.dao.Announcement;
import com.ljh.account.dao.BankAccountBinding;
import com.ljh.account.dao.BankPartner;
import com.ljh.account.dao.Resp.BankAccountBindingResp;
import com.ljh.account.mapper.BankAccountBindingMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class BankAccountBindingService {
    @Autowired
    private BankAccountBindingMapper bankAccountBindingMapper;


    public void addBinding(BankAccountBinding binding) {
        bankAccountBindingMapper.insert(binding);
    }

    public void removeBinding(Integer id) {
        bankAccountBindingMapper.deleteById(id);
    }

    public void updateBinding(BankAccountBinding binding) {
        bankAccountBindingMapper.update(binding);
    }

    public PageInfo getAllBindings(Long userid, int page, int size) {
        PageHelper.startPage(page, size);
        List<BankAccountBindingResp> list = bankAccountBindingMapper.findAll(userid);
        return new PageInfo(list);

    }

    public BankAccountBinding getBindingById(Integer id) {
        return bankAccountBindingMapper.findById(id);
    }

    public List<BankAccountBinding> filterBindings(Integer partnerId, Integer userId, String accountHolderName) {
        return bankAccountBindingMapper.filter(partnerId, userId, accountHolderName);
    }
}
